angular.module('meRecommendOrderListservices', [])

  .factory('MeRecommendOrderList', function ($resource, $rootScope, ENV, Storage) {

    //设置访问接口路径
    var APIUrl = ENV.api;

    //访问获取用户信息的接口
    var addRecommendWineResource = $resource(APIUrl + "meRecommendWine/addRecommendWine.do");

    var selectList;
    var saveOrderDetailJson;

    return{
      setSelectWineList : function(selectListFromPre){
        selectList = selectListFromPre;
      },
      getSelectWineList : function (){
        return selectList;
      },
      //保存推荐酒单
      saveOrderDetail : function(memberId,orderName,wineIdList){
        addRecommendWineResource.save(
          {
            member_id : memberId,
            mrw_name : orderName,
            wineList : wineIdList
          },
          function (data){
            saveOrderDetailJson = data;
            $rootScope.$broadcast('Me.saveOrderDetail');
          }
        );
      },

      getSaveOrderDetailJson : function (){
        return saveOrderDetailJson;
      }


    }

  });
